package service;

import java.rmi.RemoteException;

import javax.servlet.http.HttpServletRequest;

import webservices.HealthCareServerProxy;

public class ViewPosts {
	
	public String[] getPost(String username){
		String response = null;
		String[] userPostComment = null;
		HealthCareServerProxy proxy = new HealthCareServerProxy();
		try {
			response = proxy.getPosts(username);
			if(!response.isEmpty()){
				userPostComment = response.split("@");	
				System.out.println(userPostComment[0]);
				
			}
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return userPostComment;
	
	}
	
	public String[] getDocUserPost(String username, String docid){
		String response = null;
		String[] userPostComment = null;
		//HttpServletRequest request = null;
		//String username1 = request.getAttribute("userid").toString();
		//System.out.println( "inside getDocUserPost" +username1 );
		System.out.println("username in getDoc" + username);
		String username1 = username;
		HealthCareServerProxy proxy = new HealthCareServerProxy();
		try {
			
			response = proxy.getDocUserPosts( username,  docid);
			if(!response.isEmpty()){
				userPostComment = response.split("@");	
				System.out.println(userPostComment[0]);
				System.out.println("username in getDocuserport1 " + username);
			}
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("username in getDocuserport2 " + username);
		return userPostComment; 
	
	}
	
}
